import com.google.gson.Gson;
import com.sun.net.httpserver.HttpServer;

import tomcat.HttpServletRequest;
import tomcat.HttpServletResponse;
import tomcat.ServletException;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.io.IOException;

@WebServlet("/QueryBookServlet")
public class QueryBookServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private BookDao bdao = new BookDao();



    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        String name = request.getParameter("name");
        String press = request.getParameter("press");
        String date = request.getParameter("date");

        System.out.println("进来了");

        Gson gson = new Gson();
        String json = gson.toJson(bdao.query(name, press, date));
        response.getWriter().print(json);
    }


    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        doGet(request, response);
    }





}
